<?

//Data loading
$title='REPORT MASTER ADVANCE';
if (GetParam("office","")) $perush = GetCompany (GetParam("office",""));
else $perush = 'PT. MASAJI PRAYASA CARGO';

$page   = 'PAGE';

$DEFINE_FONT=0;
$pdf=new CustomerPDFReport("P","mm","Letter");
$pdf->AddPage();
$Result = CustomerList ("", "", "");
$pdf->CustomerTable($Result);
$pdf->Output();

function CustomerList ($Space, $Index, $ParentID) {
            global $RS,$Index;
            $DBConnection   = new mydb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
            if (!$Index) $Index = 0;

            $SQL = "SELECT * FROM tbladvance LEFT JOIN tbldept ON tbladvance.kddept=tbldept.kddept";

            $MyResult = $DBConnection->dbc->get_results($SQL,ARRAY_A);
            return $MyResult;
}

class CustomerPDFReport extends PDF {

    function Header() {
        global $title,$perush,$page,$DEFINE_FONT;
        if ($DEFINE_FONT==0) {
            $this->AddFont('arialn','','arialn.php');
            $DEFINE_FONT=1;
        }
        $this->SetFont('arialn','',12);
        $this->Cell(180,5,$perush,0,1,'C',0);
        $this->Cell(180,5,$title,0,1,'C',0);
        $this->Cell(180,5,$page." ".$this->PageNo(),0,1,'R',0);
        $this->Line(10,25,190,25);
        $this->Ln();
        $this->Ln();
        //Header
        //Column widths
        $w=array(20,100,60);
        $this->SetFont('arialn','',10);
        $this->Cell($w[0],7,"KODE",1,0,'C',0);
        $this->Cell($w[1],7,"NAMA",1,0,'C',0);
        $this->Cell($w[2],7,"DEPARTMENT",1,0,'C',0);
        $this->Ln();
    }

    function CustomerTable($Result) {
        //Column widths
        $w=array(20,100,60);
        //Data
        foreach($Result as $row)
        {
            $this->Cell($w[0],6,$row["kdadv"],'LR');
            $this->Cell($w[1],6,$row["advname"],'LR');
            $this->Cell($w[2],6,$row["deptname"],'LR');
            $this->Ln();
        }
        //Closure line
        //$this->Cell(array_sum($w),0,'','T');
    }

    function Footer() {
        //Closure line
        $this->Cell(180,0,'','T');
    }

}


?>
